package Code.Day1_20240918.com.dx.day01;

import java.util.ArrayList;
import java.util.Arrays;

/**
 * @ClassName Test01
 * @Description 打印超市购物小票
 * @Author 12994
 * @Date 2024/9/18 11:56
 * @Version 1.0
 **/
public class Test01 {
    /**
     * 测试类
     *
     * @param args
     */
    public static void main(String[] args) {
        // 入口
//        System.out.println("Hello World!");
//        System.out.print("Hello World!\n");

        String[] table = {"品名", "单价", "数量", "总价"};
        Object[] value = {"苹果", 2, 30};

//        ArrayList<Object> lists = new ArrayList<>();
        ArrayList<Object> _this = new ArrayList<>(Arrays.asList(value));

        System.out.println("\t\t购物清单");
        // 针对List的增强型遍历
        for (String s : table) {
            System.out.print(s + "\t\t");
        }
        System.out.print("\n");
        for (int i = 0; i <= _this.size(); i++) {
            // 总价 = 单价 * 数量
            if (i == _this.size()) {
                System.out.println((int) _this.get(i - 1) * (int) _this.get(i - 2));
            } else {
                System.out.print(_this.get(i) + "\t\t");
            }
        }
        System.out.print("\n");
    }
}
